<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>javascript</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box
    }
    body {
      font-size: 14px;
      padding: 20px;
    }
    ul li {
      line-height: 30px;
    }
  </style>
</head>
<body>
  <ul>
    <li></li>
  </ul>
</body>
<script>
  function $ajax(t) {
    return new Promise((resolve, reject) => {
      // 模拟异步请求
      setTimeout(() => {
        if (t > 2000)
          resolve(t)
        else 
          reject(t)
      }, t)
    })
  }
  async function getData(t) {
    console.log('start')
    const data = await $ajax(t)
    console.log(data)
    console.log('end')
  }
  getData(2000).then(data => {
    console.log(data)
  }, error => {
    console.log('error')
  })
</script>
</html>